/**
 *
 */
package 数据结构;

import java.util.concurrent.ConcurrentSkipListSet;

import org.junit.Before;
import org.junit.Test;

/**
 * 调表，有序而且可以范围查找
 * @Title:
 * @author zhoujie
 * @date 2019年1月17日 下午4:40:09
 *
 */
public class TConcurrentSkipListSet {
    ConcurrentSkipListSet<Integer> skipListSet;

    @Before
    public void init() {
        skipListSet = new ConcurrentSkipListSet<>();
        skipListSet.add(2);
        skipListSet.add(3);
        skipListSet.add(1);
        skipListSet.add(5);
        skipListSet.add(6);
    }

    @Test
    public void findList() {
        skipListSet.forEach(s -> {
            System.out.println(s);
        });
    }

    /**
     * 大于等于3
     */
    @Test
    public void getGt() {
        skipListSet.tailSet(3).forEach(s -> {
            System.out.println(s);
        });
    }

    /**
     * 获取3-10的范围
     */
    @Test
    public void subSet() {
        skipListSet.subSet(3, 10).forEach(s -> {
            System.out.println(s);
        });
    }
}
